package FinalProject



import grails.test.mixin.*

/**
 * See the API for {@link grails.test.mixin.domain.DomainClassUnitTestMixin} for usage instructions
 */
@TestFor(Platform)
@Mock([SiteUser,Review,Game])
class PlatformTests {

    void testSomething() {
        Platform p1 = new Platform(name: "Sega Dreamcast", dateOfRelease: "1998")
        p1.save(failOnError: true)
        Game g1 = new Game(name: "Hydro Thunder", releaseDate: "1999")
        g1.save(failOnError: true)
        Game g2 = new Game(name:"Crazy Taxi", releaseDate:"2000")
        p1.addToGames(g1)
        assertEquals(p1.games.size(), 1)
        p1.addToGames(g2)
        assertEquals(p1.games.size(), 2)
        def platforms = Platform.findAllByName("Sega Dreamcast")
        assertEquals(platforms.size(),1)
    }
}
